<%--
  Created by IntelliJ IDEA.
  User: user
  Date: 2018/9/11
  Time: 15:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>


<html>
<head>
    <title>面包线导航</title>
<%--    <script src="../assets/js/views/vue.min.js"></script>--%>
    <script src="${assets}/js/views/vue.min.js"></script>
    <style>
        #header a{
            height: 14px;
            font-family: PingFang-SC-Regular;
            font-size: 14px;
            font-weight: normal;
            font-stretch: normal;
            letter-spacing: 0px;
        }
    </style>
</head>
<body>
    <div id="header">
        <div class="page-header">
            <!-- /.page-header -->
            <ul class="page_nav" v-if="urlLib.length <= 2">
                <li class="first cur">
                    <a href="#" onClick="window.parent.showSrc('${URL_LAYOUT}')" class="cur">首页</a>
                    <span>&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                </li>
                <li class="first cur" v-for="(item,index) in urlLib" :key="index">
                    <span style="display:none;font-size:14px;font-weight: 400;">{{item.href}}</span>
                    <span class="cur" style="color:black;font-size:14px;font-weight: 400;">{{item.name}}</span>
                    <span v-if="index != urlLib.length-1" >&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                </li>
            </ul>
            <ul class="page_nav" v-else="urlLib.length >2">
                <li class="first cur">
                    <a href="#" onClick="window.parent.showSrc('${URL_LAYOUT}')" class="cur">首页</a>
                    <span>&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                </li>
                <li class="first cur" v-for="(item,index) in urlLib" :key="index">
                    <span style="display:none;font-size:14px;font-weight: 400;">{{index}}</span>
                    <span style="display:none;font-size:14px;font-weight: 400;">{{item.href}}</span>
                    <a v-if="index >= 1 && index < urlLib.length-1"  class="cur" style="color:#35acfd;font-size:14px;" onclick="prev(this)">{{item.name}}</a>
                    <span v-else-if="index < 1" class="cur" style="color:black;font-size:14px;font-weight: 400;" >{{item.name}}</span>
                    <span v-else="index == urlLib.length-1" class="cur" style="color:black;font-size:14px;font-weight: 400;" >{{item.name}}</span>
                    <span v-if="index != urlLib.length-1" >&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                </li>
            </ul>
        </div>
    </div>
    <script>
        var bv = new Vue ({
            el : "#header",
            data : {
                urlLib:[]
            },
            mounted (){
                // 初始化获取数据
                let that = this
                $.ajax({
                    url:"${URL_SCREENING_GETBREADLINE}",
                    dataType:'json',
                    type:'post',
                    success:function(data){
                      // debugger
                        that.urlLib = JSON.parse(data.data)
                    }
                })
            }
        })
        function prev(obj){
            var url = obj.parentNode.children[1].innerText
            var name = obj.innerText;
            // 获取当前的值的位置
            var num = parseInt(obj.parentNode.firstChild.innerText)
            $.ajax({
                url:"${URL_SCREENING_GETBREADLINE}",
                dataType:'json',
                type:'post',
                success:function(data){
                    breadLine = JSON.parse(data.data)
                    var bread = breadLine.slice(0,num)
                    console.log(bread)
                    var href = url.replace("amp;","")
                    console.log(href)
                    if( name.indexOf("档案") != -1 || name.indexOf("筛查") != -1 || name.indexOf("随访") != -1 || name.indexOf("问卷") != -1 || name.indexOf("报告") != -1 ){
                        href = href + '&isStorage='+1
                    }
                    bread.push({
                        name : name,
                        href : href
                    })
                    $.ajax({
                        url:'${URL_SCREENING_SAVEBREADLINE}',
                        data:{
                            breadLine:JSON.stringify(bread)
                        },
                        dataType:'json',
                        type:'post',
                        success:function(data){
                            parent.showSrc(href)
                        }
                    })
                }
            })
        }
    </script>


</body>
</html>
